package com.ruoyi.project.monitor.job.task;


import com.ruoyi.project.bajiaostar.tGoodOrder.service.ITGoodOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@EnableScheduling//开启定时任务
@Component
@Slf4j
public class SpringTimerTask {
    private static DateTimeFormatter pattern=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    @Autowired
    private ITGoodOrderService goodOrderService;

    @Scheduled(cron="0/1 * * * * ?")//每秒钟执行一次，以空格分隔
    public void cron(){
        //LocalDateTime now=LocalDateTime.now();
        //System.out.println("spring task 这是定时任务，时间是："+pattern.format(now));
    }
/*
    //执行订单过期信息
    @Scheduled(cron="0 0/1 * * * ?")//每秒钟执行一次，以空格分隔
    public void updateOrderOverdueDeteTask1 () {
        log.info("执行订单过期信息定时任务开始");
        this.goodOrderService.updateOrderOverdueDeteTask();
        log.info("执行订单过期信息定时任务结束");
    }


    //发送当日邮件
   // @Scheduled(cron="0 55 23 * * ?")//每秒钟执行一次，以空格分隔
    @Scheduled(cron="0 0/10 * * * ?")//每秒钟执行一次，以空格分隔
    public void execueOrderMailDeteTask1 () throws IOException {
        log.info("发送当日邮件定时任务开始");
        this.goodOrderService.execueOrderMailDeteTask();
        log.info("发送当日邮件定时任务开始");
    }*/
}